package cn.chengpengper.rpc.consumer.common.context;

import cn.chengpengper.rpc.proxy.api.future.RpcFuture;

/**
 * @author chengpeng.hu
 */
public class RpcContext {

    public RpcContext() {
    }

    public static final RpcContext AGENT = new RpcContext();

    private static final InheritableThreadLocal<RpcFuture> RPC_FUTURE_INHERITABLE_THREAD_LOCAL = new InheritableThreadLocal<>();

    public static RpcContext getContext() {
        return AGENT;
    }

    public void setRpcFuture(RpcFuture rpcFuture) {
        RPC_FUTURE_INHERITABLE_THREAD_LOCAL.set(rpcFuture);
    }

    public RpcFuture getRpcFuture() {
        return RPC_FUTURE_INHERITABLE_THREAD_LOCAL.get();
    }

    public void removeRpcFuture() {
        RPC_FUTURE_INHERITABLE_THREAD_LOCAL.remove();
    }
}
